<?php
namespace Home\Controller;
use Common\Model\CategoryModel;
use Org\Util\Data;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        //分配头部数据
        $conf =   [
            'js'=>['index'],
            'css'=>['index']
        ];
        $this->assign('conf',$conf);
        //获取分类数据【参考hdphp2.0手册数据处理】
        $data= (new Data())->channelLevel((new CategoryModel())->select() ,$pid = 0, $html = "&nbsp;", $fieldPri = 'cid', $fieldPid = 'pid');
        //dd($data);DIE;
        //分配数据
        $this->assign('data',$data);

        //获得商品数据
        $goodsData  =  m('goods')->limit(5)->select();
        //dd($goodsData);die;
        //获得商品数据(第一层楼)
        $goodsPhoneData  =  m('goods')->limit(6)->select();
        //分配数据
        $this->assign('goodsData',$goodsData);
        $this->assign('goodsPhoneData',$goodsPhoneData);

        //第二层楼数据
        $goodsErData  =  m('goods')->limit(7,6)->select();
        $this->assign('goodsErData',$goodsErData);

        //第三层楼数据
        $goodsSanData  =  m('goods')->limit(13,6)->select();
        $this->assign('goodsSanData',$goodsSanData);

        //第四层楼数据
        $goodsSiData  =  m('goods')->limit(19,6)->select();
        $this->assign('goodsSiData',$goodsSiData);

        //第五层楼数据
        $goodsWuData  =  m('goods')->limit(25,6)->select();
        $this->assign('goodsWuData',$goodsWuData);

        //第六层楼数据
        $goodsLiuData  =  m('goods')->limit(31,6)->select();
        $this->assign('goodsLiuData',$goodsLiuData);

        //第七层楼数据
        $goodsQiData  =  m('goods')->limit(37,6)->select();
        $this->assign('goodsQiData',$goodsQiData);

        //第七层楼数据
        $goodsBaData  =  m('goods')->limit(43,6)->select();
        $this->assign('goodsBaData',$goodsBaData);
        //新品速递
        $goodsNewData  =  m('goods')->limit(5,10)->select();
        $this->assign('goodsNewData',$goodsNewData);
        //轮播图数据
        $goodsLByiData  =  m('goods')->where("gid=8")->find();
        $goodsLBerData  =  m('goods')->where("gid=19")->find();
        $goodsLBsanData  =  m('goods')->where("gid=14")->find();
        $goodsLBsiData  =  m('goods')->where("gid=21")->find();
        $goodsLBwuData  =  m('goods')->where("gid=10")->find();
        $goodsLBliuData  =  m('goods')->where("gid=41")->find();
        $goodsLBqiData  =  m('goods')->where("gid=43")->find();

        $this->assign('goodsLByiData',$goodsLByiData);
        $this->assign('goodsLBerData',$goodsLBerData);
        $this->assign('goodsLBsanData',$goodsLBsanData);
        $this->assign('goodsLBsiData',$goodsLBsiData);
        $this->assign('goodsLBwuData',$goodsLBwuData);
        $this->assign('goodsLBliuData',$goodsLBliuData);
        $this->assign('goodsLBqiData',$goodsLBqiData);

        //加载模板
        $this->display();
    }
}